<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active1{
            background-image: url(http://seiya.wanmei.com/resources/jpg/140904/10151409820430108.jpg);
            background-size: 100vw 100vh;
        }
        .active2{
              background-image: url(http://seiya.wanmei.com/resources/jpg/140904/10151409820421441.jpg);
            background-size: 100vw 100vh;
        }
    </style>
</head>
<body>
    <button>按钮一</button>
    <button>按钮二</button>
</body>
</html>
<script>
        var btns = document.querySelectorAll("button");
        // btns[0].onclick = function(){
        //     document.body.className = "active1";
        // }
        // btns[1].onclick = function(){
        //     document.body.className = "active2";
        // }

        for(let i=0;i<btns.length;i++){
            btns[i].onclick = function(){
                // console.log(i);
                document.body.className = `active${1+i}`;
            }
        }

    </script>